<?php 
if(KT!='KhiThe') exit;
class menus_controller extends menus_model{
	
	public function __construct(){
		
		global $lang;
		
		$lang['url_base'] = url_base;	
		$this->path_cur = dirname(__FILE__);	
		parent::__construct();
		parent::addObject('khithe_template');
		parent::addObject('khithe_request');
		parent::addObject('khithe_string');
		parent::addObject('khithe_images');
		
		$this->lang = $lang;
	}
	public function index()
	{
		$this->lang['ulli_menus'] = $this->get_catproduct('0');
		
		$strModule = parent::khithe_display_template(dirname(__FILE__).'/menus');
		return $strModule = parent::khithe_assign($strModule, $this->lang);
	}
	
	public function get_catproduct($ID,$SeoKey=Null,$indent=0)
	{		
		$str = '';
		$query = parent::getMenuProducts($ID);
		$total = mysql_num_rows($query);
		if($total){
            if($indent!=0)
			$str .='<ul>';

            $indent ++;
			while($row = mysql_fetch_assoc($query))
			{				
				$str .='<li><a href="'.url_base.$row["SeoKey"].'/">'.$row["Category"].'</a>';
				$str .= $this->get_catproduct($row["ID"],$row["SeoKey"],$indent);
				$str .= '</li>';			
			}
			$str .='</ul>';
		}	
		return $str;
	}

}
?>